<template>
    <div id="background" >
        <el-container style="height:100%;" >
            <el-header id="fanKuiHeadPosition">
                <el-row type="flex" style="height:80%;display:flex;align-items: flex-end">
                    <el-col :xs="2" :sm="2" :md="2" :offset="1" class="imgCol">
                        <img v-bind:src="backIcon" class="backSize" @click="back" />
                    </el-col>
                    <el-col :xs="6" :sm="6" :md="6" :offset="6" class="imgCol">
                        <span class="titleSize">意见反馈</span>
                    </el-col>
                </el-row>
            </el-header>
            <el-main id="fanKuiMain">
                <el-row style="height:250px;">
                    <el-card shadow="always" :body-style="{ padding: '0px'}" style="height:223px;">
                        <el-input
                            type="textarea"
                            :autosize="{ minRows: 10, maxRows: 14}"
                            placeholder="说点什么吧..."
                            v-model="textarea1"
                            >
                        </el-input>
                    </el-card>
                </el-row>
                <el-row type="flex" class="imgCol">
                    <van-uploader
                        v-model="fileList"
                        multiple
                        :max-count="2"
                        class="zhaoPian"
                    />
                </el-row>
                
            </el-main>
            <div style="backgroundColor:#ffffff">
                <el-row type="flex" :class="whichPosition?'fanKuiFootPosition':'imgCol'"> 
                    <button class="yjfktjbtn" style="width: 80%;" @click="upLoad">
                       <span class="btnWords">提交</span>
                    </button>
                </el-row>
         </div>
        </el-container>
    </div>    
</template>
<script>
import { Toast } from 'vant';
import { Uploader } from 'vant'
import img from '../../assets/img/mine/tianJiaZhaoPian.png'
import backIcon from '../../assets/img/mine/back.png'
export default {
    watch:{
        showHeight(val){
            //console.log("shoHeight"+this.showHeight);
            this.whichFoot();
        },
    },
    data(){
       return{
           whichPosition:true,
            //实时屏幕高度
            showHeight:document.documentElement.clientHeight,
            height:document.documentElement.clientHeight,
            fileList: [],
            // uploadShow:true,
            backIcon:backIcon,
            // imageUrl: img,
            textarea1: '',
            // normalHeight:document.documentElement.clientHeight,
       }
    },
    mounted(){
        // window.onresize监听页面高度的变化
        const that = this;
        window.onresize = () => {
            return (() => {
                window.screenHeight=document.documentElement.clientHeight;
               that.showHeight=window.screenHeight;
            })()
         }

        var normalHeight=sessionStorage.getItem('normalHeight');

        var bg = document.getElementById("background");
       // this.normalHeight=document.documentElement.clientHeight;
        console.log("height:"+normalHeight);
        bg.style.height = normalHeight+"px";
        bg.style.backgroundColor = "#FFFFFF"
        bg.style.margin = "0px";

        var head=document.getElementById("fanKuiHeadPosition");
        var headHeight=normalHeight/30 *4 ;
        console.log("headHeight:"+headHeight);
        head.style.height=headHeight+"px";

        var main=document.getElementById("fanKuiMain");
        var mainHeight=normalHeight/30 *22 ;
        main.style.height=mainHeight+"px";
    },
    methods:{
        whichFoot(){
            if(this.showHeight<this.height){
                //console.log("foot not fixed");
                this.whichPosition=false;
            }else{
                //console.log("foot fixed");
                this.whichPosition=true;
            }
        },

        upLoad(){
            const formData = new FormData();
            formData.append("opinionText", this.textarea1);
            formData.append('opinionPicture', this.fileList);
            var URL=this.IP.IP+'/system/publishOpinion';
            console.log(this.fileList);
            console.log(formData);
            this.$ajax({
                    method:'put',
                    url:URL,
                    data:formData,
                }).then(response =>{
                    if(response.data.code==0){
                        Toast(response.data.data);
                        this.fileList=[];
                        this.textarea1='';
                    }
                console.log(response);
                }).catch(error => {
                console.log('反馈失败');
                });
        },
        back(){
            console.log("back:");
            this.$router.go(-1);
        },
    }
}
</script>
<style>
.btnWords{
    text-align: center;
    font-size: 16px;
    font-weight: 400;
    color: #FFFFFF;
}
.yjfktjbtn{
    line-height: 40px;
    width: 80%;
    background-color: #53cdf5;
    border-style: none;
    outline: none;
    -webkit-border-radius: 25px;
    -moz-border-radius: 25px;
    -ms-border-radius: 25px;
    -o-border-radius: 25px;
    border-radius: 25px;
}
.fanKuiFootPosition{
    position:fixed;
    bottom:10px;
    width:100%;
    display:flex;
    align-items:center;
    justify-content:center
}
.imgCol{
    display:flex;
    align-items:center;
    justify-content:center
}
#fanKuiHeadPosition {
  background-color: #53cdf5;
}
.backSize{
    height: 26px;
}
.titleSize{
    font-size:1.125em;
    color:#ffffff
}
@media screen and (max-height: 600px){
  .backSize{
      height: 22px;
  }
  .titleSize{
      font-size: 1em;
  }
}
.tj{
    display: flex;
    justify-content: center;
    align-items: center;
}
#fanKuiMain{
    padding:15px;
    background: #FFFFFF;
}
</style>
